/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package org.aroundme.model;

import java.util.List;
import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aroundme.persistency.PlaceManager;
/**
 * This class is responsible for cleaning up expired places in the
 * database. The class is automatically launched by a Spring
 * scheduler
 */
public class PlaceCleaner extends TimerTask {
	private static Log log = LogFactory.getLog(PlaceCleaner.class);
	private PlaceManager placeManager = null;

	public PlaceCleaner() {
	}
	
	/**
	 * cleans the expired places from the DB
	 */
	private synchronized void cleanPlaces(){
//		 retrieve expired places
//		List<Place> places = placeManager.retrieveExpiredPlaces();
//		if (places != null) {
//			for (Place place : places) {
//				placeManager.deletePlace(place);
//			}
//			log.info("Expired places clean process done: " + places.size() + " place(s) cleaned");
//		}
		
		log.info("Expired (places) clean process: CLEANER DISABLED!");
	}

	public void run() {
		cleanPlaces();
	}
	
	/*
	 * Getters and Setters 
	 */
	
	public PlaceManager getPlaceManager() {
		return placeManager;
	}

	public void setPlaceManager(PlaceManager placeManager) {
		this.placeManager = placeManager;
	}
}
